home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh -e
-
- if [ "$1" = "configure" ]; then
- . /usr/share/debconf/confmodule
- fi
-
- # Set an entry in sysctl.conf
- set_sysctl() {
- if [ -n "$2" ]; then
- return
- elif [ "$2" = "no" ]; then
- value=0
- else
- value=1
- fi
-
- if [ -e /etc/sysctl.conf ]; then
- if grep "^$1=" /etc/sysctl.conf >/dev/null 2>&1; then
- echo >> /etc/sysctl.conf
- echo "# From /etc/network/options; commented out due to your setting above" >> /etc/sysctl.conf
- echo "#$1=$value" >> /etc/sysctl.conf
- elif grep "^# *$1=" /etc/sysctl.conf >/dev/null 2>&1; then
- sed -i -e "s,^# *$1=.*,$1=$value," /etc/sysctl.conf
- else
- echo >> /etc/sysctl.conf
- echo "# From /etc/network/options" >> /etc/sysctl.conf
- echo "#$1=$value" >> /etc/sysctl.conf
- fi
- else
- echo >> /etc/sysctl.conf
- echo "# From /etc/network/options" >> /etc/sysctl.conf
- echo "#$1=$value" >> /etc/sysctl.conf
- fi
- }
-
- # Convert the options file into sysctl.conf
- migrate_options_file() {
- [ -n "$2" -a -e /etc/network/options ] || return 0
- dpkg --compare-versions "$2" lt "4.24ubuntu1" || return 0
-
- . /etc/network/options
-
- set_sysctl "net/ipv4/conf/all/rp_filter" "$spoofprotect"
- set_sysctl "net/ipv4/ip_forward" "$ip_forward"
- set_sysctl "net/ipv4/tcp_syncookies" "$syncookies"
-
- rm -f /etc/network/options
- }
-
- remove_old_files() {
- rm -f /etc/cron.daily/netbase /etc/network/spoof-protect
- }
-
- kill_portmapper() {
- if [ "$2" ] && dpkg --compare-versions $2 lt "3.11-2"; then
- if /usr/bin/rpcinfo -u localhost portmapper >/dev/null 2>&1; then
- # portmapper's still running. stop it.
-
- if [ -x /bin/fuser ]; then
- PID=$(/bin/fuser -n tcp sunrpc | sed 's/^.*: *//')
- fi
-
- if [ "$PID" ]; then
- if [ ! -f /var/run/portmap.upgrade-state ]; then
- echo >&2 "Remembering old rpc services... "
- pmap_dump >/var/run/portmap.upgrade-state
- echo >&2 "done."
- fi
- echo >&2 -n "Killing portmapper... "
- kill $PID
- echo >&2 "done."
- fi
- fi
- fi
- }
-
- update_hosts_file() {
- if [ -f /etc/hosts ] && ! grep -q "ip6-localhost" /etc/hosts; then
- cat >>/etc/hosts <<-EOF
-
- # The following lines are desirable for IPv6 capable hosts
- # (added automatically by netbase upgrade)
-
- ::1 ip6-localhost ip6-loopback
- fe00::0 ip6-localnet
- ff00::0 ip6-mcastprefix
- ff02::1 ip6-allnodes
- ff02::2 ip6-allrouters
- ff02::3 ip6-allhosts
- EOF
- fi
- }
-
- update_initd_networks() {
- if [ "$2" ] && dpkg --compare-versions "$2" lt "3.17-1"; then
- if [ -e /etc/init.d/network ]; then
- cat >> /etc/init.d/network <<EOF
-
- # (added automatically by netbase upgrade)
- #
- # In new Debian installations, this file is deprecated in favour of
- # the ifup/ifdown commands (invoked from /etc/init.d/networking), which
- # can be configured from the file /etc/network/interfaces.
- #
- # If you are receiving SIOCADDRT errors, they can be avoided by adding
- # a netmask and interface to your "route add -net" lines. eg,
- # route add -net 127.0.0.0
- # becomes:
- # route add -net 127.0.0.0 netmask 255.0.0.0 lo
- #
- # Alternatively, these lines can simply be deleted if you don't use 2.0.x
- # series kernels.
- EOF
- fi
- fi
- }
-
- fix_old_initscript() {
- if [ -e /etc/init.d/netbase ]; then
- mv /etc/init.d/netbase /etc/init.d/netbase.old
- fi
-
- if [ "$2" ] && dpkg --compare-versions "$2" lt "3.18-1"; then
- # only do this for people who were running unstable
- if dpkg --compare-versions "$2" ge "3.16-1"; then
- echo >&2 "BUGFIX: Resetting runlevels at which /etc/init.d/networking is run."
- update-rc.d -f networking remove > /dev/null 2>&1
- fi
-
- update-rc.d -f netbase remove > /dev/null 2>&1
- fi
- if [ "$2" ] && dpkg --compare-versions "$2" lt "4.24ubuntu2"; then
- update-rc.d -f networking remove > /dev/null 2>&1
- fi
-
- # Remove shutdown and reboot links; this init script does not need them.
- if dpkg --compare-versions "$2" lt "4.25ubuntu2"; then
- rm -f /etc/rc0.d/S35networking /etc/rc6.d/S35networking
- fi
- }
-
- update_rc() {
- update-rc.d networking start 40 S . > /dev/null
- }
-
- case "$1" in
- configure)
- migrate_options_file "$@"
- #remove_options_file "$@"
- remove_old_files
- kill_portmapper "$@"
- update_hosts_file
- update_initd_networks "$@"
- fix_old_initscript "$@"
- update_rc
- ;;
-
- abort-upgrade|abort-remove|abort-deconfigure)
- ;;
-
- *)
- echo "postinst called with unknown argument '$1'" >&2
- exit 1
- ;;
- esac
-
-
-
- # shouldn't be necessary? but without it the postinst just hangs on dpkg -i :(
- #
- # do i have to do this right at the end, or can i do it earlier, for that
- # matter?
- #
- # i may be meant to redirect 3>&1 or something equally weird here :-/
- # maybe this isn't necessary anymore (since there shouldn't be any daemons
- # in this postinst anymore), but who knows?
- #
- if [ "$1" = "configure" ]; then
- db_stop
- fi
-